<?php
class Pacient_model extends CI_Model {

	
		public function get_jedalnicek()
	{
		
		$query = $this->db->query('SELECT Jedlo.Nazov_jedla FROM Jedlo');
		return $query->result_array();
	}
	
	
	public function povolene_jedla()
	{
	// zisti jedla ktore moze mat pacient na zaklade zakazanych surovin



$this->db->select('Jedlo.Nazov_jedla');
 $this->db->from('Jedlo');
$this->db->join('Obsahuje','Obsahuje.Nazov_jedla = Jedlo.Nazov_jedla');
$this->db->join('Ingrediencia','Obsahuje.Nazov = Ingrediencia.Nazov');
$this->db->join('ZakazanaIngrediencia','Ingrediencia.Nazov != ZakazanaIngrediencia.Nazov');
$this->db->join('Dieta','ZakazanaIngrediencia.Dieta = Dieta.Meno');
//$this->db->join('Pacient','Pacient.Dieta = Dieta.Meno');
$this->db->where('Dieta.Meno', $this->session->userdata('Dieta'));
$this->db->distinct();

 $query = $this->db->get();

  return $query->result_array();
	}
	
}/*SELECT Jedlo.Nazov_jedla
FROM Jedlo,Pacient,Dieta,ZakazanaIngrediencia, Obsahuje
WHERE Pacient.Rodne_cislo = 9606074448 AND Pacient.dieta = Dieta.Meno AND
 ZakazanaIngrediencia.dieta = Dieta.meno AND Obsahuje.Nazov_jedla = Jedlo.Nazov_Jedla AND Obsahuje.Nazov = ZakazanaIngrediencia.Nazov');
*//*
  $this->db->select('Meno');
 $this->db->from('Dieta_ma_jedlo');
 $this->db->join('Dieta', 'Dieta_ma_jedlo.Z_diety = $Dieta');*/